﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;

namespace BLL
{
    public class ContactUsBLL : BaseBLL
    {
        public void SaveContact(String mTenKH, String mSDT, String mEmail, String mTieuDe, String mNoiDung)
        {
            Contact myContact = new Contact()
            {
                TenKhachHang = mTenKH,
                SoDienThoai = mSDT,
                Email = mEmail,
                TieuDe = mTieuDe,
                NoiDung = mNoiDung,
                ThoiDiem = DateTime.Now
            };
            DB.Contacts.InsertOnSubmit(myContact);
            DB.SubmitChanges();
        }

        public Contact LayTheoMa(int ma)
        {
            return DB.Contacts.Where(tt => tt.Ma == ma).FirstOrDefault();
        }

        public void Xoa(int ma)
        {
            Contact myContact = LayTheoMa(ma);
            DB.Contacts.DeleteOnSubmit(myContact);

            DB.SubmitChanges();
        }
    }
}
